package cn.cdiothree.controller;


import cn.cdiothree.dataobject.ProductCategory;
import cn.cdiothree.service.ProductCategoryService;
import cn.cdiothree.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author CumThing
 * @since 2020-02-02
 */
@RestController
@RequestMapping("/categories")
@CrossOrigin(origins = {"*"},allowCredentials = "true")
public class ProductCategoryController {

    @Autowired
    ProductCategoryService productCategoryService;

    /**
     * 获取所有商品类目
     * @return
     */
    @GetMapping("/all")
    public ResultVo get() {
        List<ProductCategory> productCategories = productCategoryService.findAll();
        return ResultVo.success(productCategories);
    }

}
